package task1;

import java.util.Arrays;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 东莞呵呵
 * Date:2022-05-10
 * Time:16:42
 */
public class TestDemo4 {
    public static void main(String[] args) {
        int[] arr={9,8,7,6,5,4,3,2,1};

        for (int i = 0; i < arr.length; i++) {
            boolean flg=false;
            for (int j = 0; j < arr.length-1-i; j++) {
                if(arr[j]>arr[j+1]){
                    int tmp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1]=tmp;
                    flg=true;
                }
                if(!flg){
                    break;
                }
            }
        }
        System.out.println(Arrays.toString(arr));
    }
}
